from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome("C:\Program Files\driver\chromedriver.exe")
driver.maximize_window()

driver.get("https://www.baidu.com")

driver.find_element(By.CSS_SELECTOR, "#kw").send_keys('坚果')
driver.find_element(By.CSS_SELECTOR, "#su").click()

time.sleep(3)

for i in range(5):
    x = 0
    y = 500*(i+1)
    # js = 'window.scrollTo({},{})'.format(x, y)
    js = 'var q=document.documentElement.scrollTop={}'.format(y)
    driver.execute_script(js)
    time.sleep(2)

driver.quit()